package data.goods;

import java.io.Serializable;
import java.util.ArrayList;

import data.ListInterIterator;

public class StockRecord  implements Serializable{
	private boolean type;
	public String ID;
	private String date;
	private String exportID;
	private ArrayList<GoodsStockRecord> goodsstockrecords;
	
	public StockRecord(boolean type,String date, String exportID, ListInterIterator<GoodsStockRecord> goodsstocks){
		this.type=type;
		String typestock;
		if(type==true){
		  typestock="t";	
		}
		else{
			typestock="f";
		}
		this.ID=date+"&"+typestock+"&"+exportID;
		this.date=date;
		this.exportID=exportID;
		this.goodsstockrecords=goodsstocks.toArray();
	}
	
	public boolean getType(){
		return type;
	}
	
	public void setType(boolean type){
		this.type=type;
	}
	
	
	public String getID(){
		return ID;
	}
	
	public void setID(String ID){
		this.ID=ID;
	}
	
	public String getDate(){
		return date;
	}
	
	public void setDate(String date){
		this.date=date;
	}
	
	public String getExportID(){
		return exportID;
	}
	
	public void setExportID(String exportID){
		this.exportID=exportID;
	}
	
	public ListInterIterator<GoodsStockRecord> get(){
		return new ListInterIterator<GoodsStockRecord>(goodsstockrecords);
	}
	
	public int findGoodsStockRecord(String goodstypeID){
		int num=0;
		for(int i=0;i<goodsstockrecords.size();i++){
			if(goodsstockrecords.get(i).getGoodsTypeID().equals(goodstypeID));
			num=goodsstockrecords.get(i).getNum();
			break;
		}
		return num;
		
	}
	
	public String toString(){
		
		return String.valueOf(type)+" "+ID+" date "+date+" "+exportID+" ";//goodsstockrecords
	}

	public GoodsStockRecord findGoodsType(String goodsTypeID) {
		GoodsStockRecord temp=null;
		for(int i=0;i<goodsstockrecords.size();i++){
			if(goodsstockrecords.get(i).getGoodsTypeID().equals(goodsTypeID)){
				 temp=goodsstockrecords.get(i);
				 break;
			}
		}
		return temp;
	}
	
	

}
